//
//  WYClueController.m
//  CirclePush
//
//  Created by admin on 2018/4/19.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "WYClueController.h"

@interface WYClueController ()
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *topHeight;
@property (strong, nonatomic) IBOutlet UIButton *AdBtn;

@property (strong, nonatomic) IBOutlet UIButton *mediaBtn;
@property (strong, nonatomic) IBOutlet UITextField *userName;
@property (strong, nonatomic) IBOutlet UITextField *userMobile;




@end

@implementation WYClueController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self setupUI];
}
-(void)setupUI
{
    [self initTopBarWithTitle:@"新增线索"];
    [self addLeftButton:[UIImage imageNamed:@"return"] width:0 height:0];
    self.view.backgroundColor = [UIColor hexStringToColor:@"#f4f4f4" alpha:1.0];
    
    if (kDevice_Is_iPhoneX) {
        self.topHeight.constant = 98;
    }
    self.AdBtn.selected = YES;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
- (IBAction)clickAdAction:(id)sender {
    UIButton *btn = (UIButton *)sender;
    btn.selected = YES;
    self.mediaBtn.selected = NO;
}
- (IBAction)clickMediaAction:(id)sender {
    UIButton *btn = (UIButton *)sender;
    btn.selected = YES;
    self.AdBtn.selected = NO;
}
- (IBAction)clickSubmissionAction:(id)sender {
    if (!self.userName.text.length) {
        [self toast:@"请输入姓名"]; return;
    }
    if (!self.userMobile.text.length) {
        [self toast:@"请输入手机号"];return;
    }
    NSString *mediatype = @"";
    if (self.AdBtn.isSelected) {
        mediatype = @"4";
    }else{
        mediatype = @"5";
    }
    
    
    WEAKSELF
    [WYHttpServer submissiondemandWithLinkeMan:self.userName.text WithTelephone:self.userMobile.text WithEmail:nil WithMediaType:@"4" WithMediaId:nil SucessBlock:^(BOOL success, id response, NSString *errorMessage) {
        if (success) {
            [weakSelf toast:@"提交成功"];
            [weakSelf.navigationController popViewControllerAnimated:YES];
        }else{
            [weakSelf toast:errorMessage];
        }
    }];
    
    
    
    
    
}

@end
